home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / em-xmkit.zip / EMM23_A.ASM < prev    next >
Assembly Source File  |  1989-11-29  |  14KB  |  203 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;      MODULE NAME:   EMM23_A.ASM                                             ;
  3. ;                                                                             ;
  4. ;    FUNCTION NAME:   alter_map_call                                          ;
  5. ;                                                                             ;
  6. ;      DESCRIPTION:   This function saves the current memory mapping context, ;
  7. ;                     alters the specified memory mapping context, and        ;
  8. ;                     transfers control to the specified address.  It is      ;
  9. ;                     analogous to the FAR CALL in the 8086 family            ;
  10. ;                     architecture.  Just as a return from a FAR CALL         ;
  11. ;                     restores the original value in the code segment         ;
  12. ;                     register, this function restores the state of the       ;
  13. ;                     specified mapping context after the return.             ;
  14. ;                                                                             ;
  15. ;                     There is no explicit expanded memory function which     ;
  16. ;                     emulates a return from a FAR CALL.  However, this       ;
  17. ;                     facility is implicitly available through the standard   ;
  18. ;                     return from a FAR CALL.  The following paragraphs       ;
  19. ;                     describe how this works:                                ;
  20. ;                                                                             ;
  21. ;                     After this function is invoked, unless an error is      ;
  22. ;                     detected, the memory manager will transfer control to   ;
  23. ;                     the address specified.  If an error occurs, the memory  ;
  24. ;                     manager returns immediately with the error status.      ;
  25. ;                     Otherwise, the memory manager pushes on the stack       ;
  26. ;                     information which enables it to restore the mapping     ;
  27. ;                     context after the return.                               ;
  28. ;                                                                             ;
  29. ;                     When the called procedure wants to return to the        ;
  30. ;                     calling procedure, it simply issues a standard FAR      ;
  31. ;                     RETURN.  The memory manager traps this return, restores ;
  32. ;                     the specified mapping context, and returns to the       ;
  33. ;                     calling procedure.  The memory manager also returns a   ;
  34. ;                     status from a successful return just as it does for all ;
  35. ;                     functions.                                              ;
  36. ;                                                                             ;
  37. ;                     Developers using this function must make allowances for ;
  38. ;                     the additional stack space this function will use.      ;
  39. ;                                                                             ;
  40. ;           PASSED:   mode:                                                   ;
  41. ;                        is a flag which indicates whether the value          ;
  42. ;                        contained in the init_map.phys_page_or_seg &         ;
  43. ;                        final_map.phys_page_or_seg structure members are a   ;
  44. ;                        physical page number or the segment address          ;
  45. ;                        representation of the physical page numbers.  A zero ;
  46. ;                        indicates that the values are physical page numbers. ;
  47. ;                        A one indicates that the values in these members     ;
  48. ;                        are the segment address representations of the       ;
  49. ;                        physical page numbers.                               ;
  50. ;                                                                             ;
  51. ;                                                                             ;
  52. ;                     &mc:                                                    ;
  53. ;                        is a far pointer to a structure which contains the   ;
  54. ;                        information necessary to map the desired physical    ;
  55. ;                        pages and call the target address.                   ;
  56. ;                        The structure members are described here:            ;
  57. ;                                                                             ;
  58. ;                        mc.target_function:                                  ;
  59. ;                           is a far pointer which contains the target        ;
  60. ;                           address to which control is to be transferred.    ;
  61. ;                           The application must supply this is value.        ;
  62. ;                                                                             ;
  63. ;                        mc.init_map_struct_count:                            ;
  64. ;                           is the number of entries in the initial mapping   ;
  65. ;                           context to which mc.ptr_init_map_struct points.   ;
  66. ;                           This number cannot exceed the number of mappable  ;
  67. ;                           pages in the system.                              ;
  68. ;                                                                             ;
  69. ;                        mc.ptr_init_map_struct:                              ;
  70. ;                           is a far pointer to an array of structures which  ;
  71. ;                           contains a list of the logical page numbers and   ;
  72. ;                           the physical page numbers/segments at which they  ;
  73. ;                           are to be mapped immediately BEFORE the call.     ;
  74. ;                           The init_map array of structures is described at  ;
  75. ;                           the end of the mc structure.                      ;
  76. ;                                                                             ;
  77. ;                        mc.final_map_struct_count:                           ;
  78. ;                           is the number of entries in the final mapping     ;
  79. ;                           context to which mc.ptr_final_map_struct points.  ;
  80. ;                           This number cannot exceed the number of mappable  ;
  81. ;                           pages in the system.                              ;
  82. ;                                                                             ;
  83. ;                        mc.ptr_final_map_struct:                             ;
  84. ;                           is a far pointer to an array of structures which  ;
  85. ;                           contains a list of the logical page numbers and   ;
  86. ;                           the physical page numbers/segments at which they  ;
  87. ;                           are to be mapped immediately AFTER the return.    ;
  88. ;                           The final_map array of structures is described    ;
  89. ;                           at the end of the mc structure.                   ;
  90. ;                                                                             ;
  91. ;                        mc.reserved:                                         ;
  92. ;                           is a character array which is reserved for use by ;
  93. ;                           the memory manager.                               ;
  94. ;                                                                             ;
  95. ;                     init_map                                                ;
  96. ;                     & final_map:                                            ;
  97. ;                        are arrays of structures which contain lists of the  ;
  98. ;                        logical page numbers and the physical page           ;
  99. ;                        numbers/segments at which they are to be mapped.     ;
  100. ;                        The init_map array of structures specifies the       ;
  101. ;                        mapping immediately BEFORE the CALL.  The final_map  ;
  102. ;                        array of structures specifies the mapping            ;
  103. ;                        immediately AFTER the RETURN.                        ;
  104. ;                        The structure members are described here:            ;
  105. ;                                                                             ;
  106. ;                        init_map.log_page                                    ;
  107. ;                        & final_map.log_page:                                ;
  108. ;                           is the logical page to be mapped.                 ;
  109. ;                                                                             ;
  110. ;                        init_map.phys_page_or_seg                            ;
  111. ;                        & final_map.phys_page_or_seg:                        ;
  112. ;                           is either the physical page number or the         ;
  113. ;                           segment address representation of the physical    ;
  114. ;                           page number at which the previous logical page    ;
  115. ;                           number is to be mapped.  The mode passed          ;
  116. ;                           determines the type of representation.            ;
  117. ;                                                                             ;
  118. ;                     handle:                                                 ;
  119. ;                        is an open EMM handle.                               ;
  120. ;                                                                             ;
  121. ;         RETURNED:   status:                                                 ;
  122. ;                        is the status EMM returns from the call.  All other  ;
  123. ;                        returned results are valid only if the status        ;
  124. ;                        returned is zero.  Otherwise they are undefined.     ;
  125. ;                                                                             ;
  126. ; C USE CONVENTION:   unsigned int    status;                                 ;
  127. ;                     unsigned int    mode;                                   ;
  128. ;                     unsigned int    handle;                                 ;
  129. ;                     MAP_STRUCT      init_map [MAX_MAPPABLE_REGIONS];        ;
  130. ;                     MAP_STRUCT      final_map [MAX_MAPPABLE_REGIONS];       ;
  131. ;                     MAP_CALL_STRUCT mc;                                     ;
  132. ;                                                                             ;
  133. ;                     init_map[0].log_page          = 0;                      ;
  134. ;                     init_map[0].phys_page_or_seg  = 0xC000;                 ;
  135. ;                                                                             ;
  136. ;                     final_map[0].log_page         = 1;                      ;
  137. ;                     final_map[0].phys_page_or_seg = 0xC000;                 ;
  138. ;                     final_map[1].log_page         = 2;                      ;
  139. ;                     final_map[1].phys_page_or_seg = 0xC400;                 ;
  140. ;                                                                             ;
  141. ;                     mode = SEG_MODE;                                        ;
  142. ;                     mc.target_function        = 0xC0000000;                 ;
  143. ;                     mc.init_map_struct_count  = 1;                          ;
  144. ;                     mc.ptr_init_map_struct    = init_map;                   ;
  145. ;                     mc.final_map_struct_count = 2;                          ;
  146. ;                     mc.ptr_final_map_struct   = final_map;                  ;
  147. ;                                                                             ;
  148. ;                     status = alter_map_call (mode,                          ;
  149. ;                                              &mc,                           ;
  150. ;                                              handle);                       ;
  151. ;-----------------------------------------------------------------------------;
  152. .XLIST
  153. PAGE    60,132
  154.  
  155. IFDEF SMALL
  156.    .MODEL SMALL, C
  157. ENDIF
  158. IFDEF MEDIUM
  159.    .MODEL MEDIUM, C
  160. ENDIF
  161. IFDEF LARGE
  162.    .MODEL LARGE, C
  163. ENDIF
  164. IFDEF COMPACT
  165.    .MODEL COMPACT, C
  166. ENDIF
  167. IFDEF HUGE
  168.    .MODEL HUGE, C
  169. ENDIF
  170.  
  171. INCLUDE emmlib.equ
  172. INCLUDE emmlib.str
  173. INCLUDE emmlib.mac
  174. .LIST
  175. .CODE
  176.  
  177. alter_map_call        PROC                                                  \
  178.             USES DS SI,                                           \
  179.             mode:BYTE,                                            \
  180.             ptr_map_struct:FAR PTR BYTE,                              \
  181.             handle:WORD
  182.  
  183.     ;---------------------------------------------------------------------;
  184.     ;   do;                                                               ;
  185.     ;   .   alter the current mapping context & call the procedure at     ;
  186.     ;   .   the target address;                                           ;
  187.     ;---------------------------------------------------------------------;
  188.     MOVE        AH, alter_page_map_and_call_fcn
  189.     MOVE        AL, mode
  190.     MOVE        DX, handle
  191.     MOVE        DS:SI, ptr_map_struct
  192.     INT         EMM_int
  193.  
  194.     ;---------------------------------------------------------------------;
  195.     ;   .   return (EMM status);                                          ;
  196.     ;   end;                                                              ;
  197.     ;---------------------------------------------------------------------;
  198.     RET_EMM_STAT    AH
  199.  
  200. alter_map_call        ENDP
  201.  
  202. END
  203.